<?php  $payslip_user_id = $this->session->flashdata('payslip_user_id');?>
<?php  if(!empty($payslip_user_id)){ ?>
<div class="alert">
<?php echo $this->session->flashdata('payslip_msg');?>
</div>
<?php }?>
<h3 class="widget-name">Create Salary</h3>

<?= form_open('founder/salary/create_salary')?>
<div class="row-fluid"> 
	<div class="span6">
	<table class="">
  <tr>
    <td width="20%">For</td>
    <td width="40%">
    <select name="user" class="chzn-select span12">
    <option value="">-- Select User -- </option>
    <?php foreach($users as $user) {
		if(!$this->ion_auth->is_client($user->id) AND $this->ion_auth->is_active($user->id) AND !$this->ion_auth->is_admin($user->id)){	
		?>
    <option value="<?= $user->id?>" <?php if($payslip_user_id == $user->id){echo 'selected="selected"';} ?> > <?= ucwords($user->username);?> </option>
    <?php } }?>
    </select><br />
	<?= form_error('user')?>  </td>
    
  </tr>
  <tr>
    <td>Basic  <small class="text-info">( Per month)</small></td>
    <td>
	<div class="input-prepend span10">
  <span class="add-on">Rs.</span>
  <input class="salary span12" id="prependedInput" type="text" placeholder="in ruppes" name="basic_pay" value="<?=set_value('basic_pay')?>">
</div>
 <?= form_error('basic_pay')?>
</td>    
  </tr>
  <tr>
    <td>Per day <small class="muted">( Total Salary / 30 )</small></td>
    <td><div class="input-prepend">
  <span class="add-on">Rs.</span>
  <input class="per_day span5" id="prependedInput" type="text" placeholder="" name="per_day_salary"  value="<?=set_value('per_day_salary')?>" readonly="readonly" >
  	<?= form_error('per_day_salary')?>   
  </td>
    
  </tr>
  <tr>
  <td>Minimum Working Hour</td>
    <td>
    <div class="input-append">
  
  <input class="min_working_hour span4" id="prependedInput" type="text" placeholder="" name="min_working_hour"  value="<?=set_value('min_working_hour')?>">
  <span class="add-on">Hr.</span>
  </div>
  <?= form_error('min_working_hour')?> 
    </td>      
  </tr>
  <tr>
    <td>Per hour <small class="muted">(   per day / working hour )</small></td>
    <td><div class="input-prepend">
  <span class="add-on">Rs.</span>
  <input class="per_hour span4" id="prependedInput" type="text" placeholder="" name="per_hour_salary"  value="<?=set_value('per_hour_salary')?>"  readonly="readonly">
  </div>	
  <?= form_error('per_hour_salary')?>   
   </td>    
  </tr>
  <tr>
    <td>Paid Leave Allowed <small>(per year)</small></td>
    <td><input type="text" class="span3" name="paid_leave" value="<?=set_value('paid_leave')?>"/>
	<?= form_error('paid_leave')?>
	</td>
    
  </tr>
  <tr>
    <td>Paid Leave / per month</td>
    <td><input type="text" class="span3"  name="per_month_leave" value="<?=set_value('per_month_leave')?>"/>
	<?= form_error('per_month_leave')?>
	</td>
    
  </tr>
 
</table>	
		
	</div>
	<div class="span6">
		<table width="100%">
			<tr>
				<td>Travelling Allowances</td>
				<td>
				<div class="input-prepend">
  <span class="add-on">Rs.</span>
  <input id="prependedInput" type="text" placeholder="" name="travelling_allowances"  value="<?= set_value('travelling_allowances')?>" >
  </div>
				</td>
			</tr>
			
			<tr>
				<td>HRA</td>
				<td>
					<div class="input-prepend">
  <span class="add-on">Rs.</span>
  <input id="prependedInput" type="text" placeholder="" name="hra" value="<?= set_value('hra');?>" >
  </div></td>
			</tr>
			<tr>
				<td>Bank A/C no.</td>
				<td><input type="text" name="bank_ac" value="<?= set_value('bank_ac');?>"/></td>
			</tr>
		 <tr>
    <td>&nbsp;</td>
    <td><input type="submit" value="Create Salary" class="btn btn-info btn-small" />
    <input type="reset" class="btn btn-danger btn-small "/>
    </td>    
  </tr>	
		</table>
	</div>
</div>

</form>

<script type="text/javascript">
$(".salary").change(function() {
	var salary = $(".salary").val();
	
	var per_day = salary / 30;
	var per_hour = 
	$('.per_day').val(per_day.toFixed(2));	
	
	if($('.min_working_hour').val())
	{
	$('.per_hour').val(($('.per_day').val() / $('.min_working_hour').val()).toFixed(2));
	}
	
	})
	
/*$(".salary").focus( function () {	
	$('.per_day').val(""); 
	})	*/
	
	$('.min_working_hour').change(function () {
		
		$('.per_hour').val(($(".per_day").val() / $('.min_working_hour').val()).toFixed(2));
		
		})
		
		$('.per_day').change(function () {
			
			
			})
	
</script>